﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Media.Imaging;
using Tulde.MP3tunes;

namespace WP7.LockerPlayer
{
    public static class AlbumArtResource
    {
        public static BitmapImage LoadFromUrl(string url)
        {
            if (String.IsNullOrEmpty(url))
            {
                BitmapImage logo = new BitmapImage();
                return logo;
            }
            else
            {
                BitmapImage logo = new BitmapImage();

                logo.UriSource = new Uri(url);

                return logo;
            }
        }
        public static BitmapImage Load(string albumId, AlbumArtSizeOptions size = AlbumArtSizeOptions.medium)
        {
            AlbumArtService service = new AlbumArtService();
            Uri url = service.CreateServiceEndpoint(LockerDataOperations.albumartget, new AlbumArtServiceParameters
            {
                AlbumServiceKey = albumId,
                Size = size
            });

            try
            {
                BitmapImage logo = new BitmapImage();

                logo.UriSource = url;
               
                return logo;
            }
            catch
            {
                return new BitmapImage();
            }
        }
    }
}
